<?php
session_start();
$username = $_SESSION['username'];
$password = $_SESSION['password'];
$title = $_REQUEST['title'];
$desc = $_REQUEST['description'];
$tag = $_REQUEST['tag'];
$urlpath = $_REQUEST['q'];

$url = "http://localhost:8080/moms-diary/".$urlpath;
//echo $_REQUEST['data']."tess";

$postFields = "&title=".$title."&description=".$desc."&tag=".$tag;

$auth = $username.":".$password;
 
$curl_handle = curl_init($url);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_USERPWD, $auth);
curl_setopt($curl_handle, CURLOPT_POST, count($postFields));
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array("Content-type: application/x-www-form-urlencoded"));
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $postFields);

//execute the API Call
$returned_data = curl_exec($curl_handle);
$return = curl_getinfo($curl_handle);

echo $returned_data;
//print_r($return);


